package com.lance.answer.question_export.gk_new;

import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.lance.answer.dto.CourseInfo;
import com.lance.answer.dto.GkUser;
import com.lance.answer.gui.answer.Util;
import com.lance.answer.question_answer.xj_new.DoXJAnswerHomeworkTask;
import org.apache.commons.io.IOUtils;

import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.LinkedBlockingDeque;

/**
 * 学生的答题情况
 */
public class GetGkCourseInfo {

    public static void main(String[] args)  throws Exception{

        int sync = 16;
        String driverPath = null;

        LinkedBlockingDeque<GkUser> userQueue = new LinkedBlockingDeque<>();
    //    InputStream inputStream = new FileInputStream("libs//2022User.txt");
  //      String teacherName = "刘";
    //    String teacherName = "朱晓玉";
     //   String teacherName = "刘庆";
     //  String teacherName = "李俊杰";
    //   String teacherName = "宋柳萌";
       String teacherName = "零散";
   //    String teacherName = "李明";
  //      String teacherName = "艾";
        InputStream inputStream = new FileInputStream("libs//teachers//"+teacherName+".user");
        List<String> users = IOUtils.readLines(inputStream, "utf-8");

        

        
        for(String u:users){
            String[] strs = u.split(",");
            String userCode = strs[0];
//            if(!Util.getVip().contains(userCode)){
//                continue;
//            }

            String pwd = "";
            if(strs[1].length()<18){
                pwd = strs[1];
            }else {
                pwd = strs[1].substring(6, 14);
                pwd = "Ouchn" + pwd;
            }
            GkUser gkUser = new GkUser(userCode,pwd,teacherName);
            userQueue.add(gkUser);
        }


        for (int i = 1; i <= sync; i++) {
            Thread answerThread = new GetGkCourseInfoTask(driverPath,userQueue);
            //log.info("加载课程ID：{} 名称：{} ", openCourseId,subjectName);
            answerThread.setName( "答题线程--" + i);
            answerThread.start();
        }

    }

}
